package com.isoft.student.service.impl;

import com.isoft.student.dao.LogonlogMapper;
import com.isoft.student.eo.LogonlogEOPage;
import com.isoft.student.model.Logonlog;
import com.isoft.student.service.LogonlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 实现业务及流程接口当中的内容
 */
@Service
public class LogonlogServiceImpl implements LogonlogService {
    @Autowired
    private LogonlogMapper logonlogMapper;

    /**
     * 登录日志添加方式实现
     * @param logonlog 答题
     * @return 是否成功（-1 重复添加）
     */
    @Override
    public int AddLogonlog(Logonlog logonlog) {
        int returnInt=0;
        //业务判断
        //（1）答题名称不能重复

        //(1)判断答题
        int LoginaddressCount=logonlogMapper.getLoginaddressCount(logonlog.getLoginaddress());
        if (LoginaddressCount<1){
            //2.答题信息数据添加
            int addLogonlogInt=logonlogMapper.insertLogonlog(logonlog);
            //3.返回值设置
            returnInt=addLogonlogInt;
        }else {
            returnInt=-1;//有相同的信息名称
        }

        return returnInt;
    }

    @Override
    public List<LogonlogEOPage> getLogonlogWhereAll(LogonlogEOPage logonlogEOPage) {
        List<LogonlogEOPage> listLogonlogEo=logonlogMapper.getLogonlogWhereAll(logonlogEOPage);
        return listLogonlogEo;
    }

}
